//
//  ToolNet.h
//
//  Created by suyibaishan on 15/8/26.
//  Copyright (c) 2015年 suyibaishan. All rights reserved.
//

#import "AFNetworking.h"
#import "NetCompletionBlocks.h"

@interface ToolNet : AFHTTPSessionManager

#define TIMEOUT_INTERVAL 30

//获得验证码   类型：1-注册短信；2-忘记密码短信    
#define MMobileSms [kFILEPATH stringByAppendingString:@"common/user/mobileSms"]
-(NSURLSessionDataTask *)getVerifyCode:(NSString *)mobile type:(NSInteger)type url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//注册
#define MRegCheck [kFILEPATH stringByAppendingString:@"api/v1/common/regCheck"]
-(NSURLSessionDataTask *)registerApp:(NSString *)mobile password:(NSString *)password vaidCode:(NSString *)vaidCode refereeMobile:(NSString *)refereeMobile url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//申请成为会员
#define MMemberCheck [kFILEPATH stringByAppendingString:@"api/v1/common/memberCheck"]
-(NSURLSessionDataTask *)applyForMember:(NSString *)userCode card:(NSString *)card frontCardImg:(NSString *)frontCardImg backCardImg:(NSString *)backCardImg address:(NSString *)address realName:(NSString *)realName url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//忘记密码
#define MForgetPswCheck [kFILEPATH stringByAppendingString:@"common/user/forgetPswCheck"]
-(NSURLSessionDataTask *)forgetPwd:(NSString *)mobile password:(NSString *)password vaidCode:(NSString *)vaidCode url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//VIP费用缴纳
#define MPayCheck [kFILEPATH stringByAppendingString:@"api/v1/common/payCheck"]
-(NSURLSessionDataTask *)payCheck:(NSString *)userCode payMethod:(NSString *)payMethod url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//商城首页轮播图   类型：1-首页头部轮播图;2-首页中部轮播图    
#define MBannerList [kFILEPATH stringByAppendingString:@"api/v1/common/bannerList"]
-(NSURLSessionDataTask *)getBannerList:(NSInteger)type url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//首页汽车列表
#define MCarsList [kFILEPATH stringByAppendingString:@"api/v1/common/carsList"]
-(NSURLSessionDataTask *)getCarsList:(NSString *)productName pageNum:(NSInteger)pageNum pageSize:(NSInteger)pageSize url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

// NX ADD
//汽车列表 积分的  NEW
#define MCarsList [kFILEPATH stringByAppendingString:@"api/v1/common/carsList"]
-(NSURLSessionDataTask *)getCarsList:(NSString *)productName pageNum:(NSInteger)pageNum pageSize:(NSInteger)pageSize type:(NSString *)type url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//公告列表数据
#define MAnnouncementList [kFILEPATH stringByAppendingString:@"api/v1/cus/back/announcementList"]
-(NSURLSessionDataTask *)getAnnouncementList:(NSString *)userCode accessToken:(NSString *)accessToken pageNum:(NSInteger)pageNum pageSize:(NSInteger)pageSize url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//我的页面数据
#define MUserCenter [kFILEPATH stringByAppendingString:@"api/v1/cus/user/userCenter"]
//我的购物车
#define MMyItem [kFILEPATH stringByAppendingString:@"api/v1/cus/cars/myItem"]
//我的直荐
#define MRecommend [kFILEPATH stringByAppendingString:@"api/v1/cus/team/recommend"]
//我的非直荐
#define MIndirectRecommend [kFILEPATH stringByAppendingString:@"api/v1/cus/team/indirectRecommend"]
//我的团队
#define MMyTeam [kFILEPATH stringByAppendingString:@"api/v1/cus/team/myTeam"]
//个人信息
#define MUserInfo [kFILEPATH stringByAppendingString:@"api/v1/cus/user/info"]
//我的资产
#define MUserCash [kFILEPATH stringByAppendingString:@"api/v1/cus/user/cash"]
//我的名片
#define MUserCard [kFILEPATH stringByAppendingString:@"api/v1/cus/user/card"]
//支付信息
#define MAccountInfo [kFILEPATH stringByAppendingString:@"api/v1/cus/user/accountInfo"]
//申请提现页面数据
#define MExchangePage [kFILEPATH stringByAppendingString:@"api/v1/cus/cash/exchangePage"]
-(NSURLSessionDataTask *)getUserInfo:(NSString *)userCode accessToken:(NSString *)accessToken url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//加入购物车
#define MAddItem [kFILEPATH stringByAppendingString:@"api/v1/cus/cars/addItem"]
-(NSURLSessionDataTask *)addItem:(NSString *)userCode accessToken:(NSString *)accessToken productNo:(NSString *)productNo url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//修改购物车
#define MChangeItem [kFILEPATH stringByAppendingString:@"api/v1/cus/cars/changeItem"]
-(NSURLSessionDataTask *)changeItem:(NSString *)userCode accessToken:(NSString *)accessToken itemId:(NSInteger)itemId quantity:(NSInteger)quantity url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//删除购物车
#define MDelItem [kFILEPATH stringByAppendingString:@"api/v1/cus/cars/delItem"]
-(NSURLSessionDataTask *)delItem:(NSString *)userCode accessToken:(NSString *)accessToken itemId:(NSInteger)itemId url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//购物车创建订单   itemIds 购物车商品数组
#define MCreateItemOrder [kFILEPATH stringByAppendingString:@"api/v1/cus/cars/createItemOrder"]
-(NSURLSessionDataTask *)createItemOrder:(NSString *)userCode accessToken:(NSString *)accessToken itemIds:(NSString *)itemIds orderAmount:(CGFloat)orderAmount remark:(NSString *)remark url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//立即购买
#define MCreateOrder [kFILEPATH stringByAppendingString:@"api/v1/cus/cars/createOrder"]
-(NSURLSessionDataTask *)createOrder:(NSString *)userCode accessToken:(NSString *)accessToken productNo:(NSString *)productNo orderAmount:(CGFloat)orderAmount remark:(NSString *)remark url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

// 积分商城购买
#define MCreatePointOrder [kFILEPATH stringByAppendingString:@"api/v1/cus/cars/createPointsOrder"]
- (NSURLSessionDataTask *)createPointOrder:(NSString *)userCode accessToken:(NSString *)accessToken prodectNo:(NSString *)productNo point:(NSString *)point remark:(NSString *)remark url:(NSString *)url completionHnadle:(NetResponseCompletionBlock)completionBlock;


//修改个人信息
#define MChangeInfo [kFILEPATH stringByAppendingString:@"api/v1/cus/user/changeInfo"]
-(NSURLSessionDataTask *)changeInfo:(NSString *)userCode accessToken:(NSString *)accessToken address:(NSString *)address url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//申请提现审核   支付方式：0-银行卡    提现方式:0-现金提现；1-购车基金提现
#define MCashCheck [kFILEPATH stringByAppendingString:@"api/v1/cus/cash/cashCheck"]
-(NSURLSessionDataTask *)checkCash:(NSString *)userCode accessToken:(NSString *)accessToken amount:(NSString *)amount paymethod:(NSInteger)paymethod cashType:(NSInteger)cashType url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//查看流水页面   类型：1-佣金明细;2-提现明细;
#define MExchangeRecord [kFILEPATH stringByAppendingString:@"api/v1/cus/cash/exchangeRecord"]
-(NSURLSessionDataTask *)getExchangeRecord:(NSString *)userCode accessToken:(NSString *)accessToken type:(NSInteger)type pageNum:(NSInteger)pageNum pageSize:(NSInteger)pageSize url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//我的订单
#define MOrderData [kFILEPATH stringByAppendingString:@"api/v1/cus/order/orderData"]
-(NSURLSessionDataTask *)getOrderData:(NSString *)userCode accessToken:(NSString *)accessToken pageNum:(NSInteger)pageNum pageSize:(NSInteger)pageSize url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//订单详情
#define MOrderDetail [kFILEPATH stringByAppendingString:@"api/v1/cus/order/orderDetail"]
//作废订单
#define MCancelOrder [kFILEPATH stringByAppendingString:@"api/v1/cus/order/cancelOrder"]
//删除订单
#define MDelOrder [kFILEPATH stringByAppendingString:@"api/v1/cus/order/delOrder"]
-(NSURLSessionDataTask *)managerOrders:(NSString *)userCode accessToken:(NSString *)accessToken orderId:(NSInteger)orderId url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//支付信息修改
#define MAccountInfoChange [kFILEPATH stringByAppendingString:@"api/v1/cus/user/accountInfoChange"]
-(NSURLSessionDataTask *)changeAccountInfo:(NSString *)userCode accessToken:(NSString *)accessToken bankHolder:(NSString *)bankHolder bankNumber:(NSString *)bankNumber bankName:(NSString *)bankName url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;

//修改密码
#define MChangePswCheck [kFILEPATH stringByAppendingString:@"api/v1/cus/user/changePswCheck"]
-(NSURLSessionDataTask *)changePsw:(NSString *)userCode accessToken:(NSString *)accessToken oldPsw:(NSString *)oldPsw newPsw:(NSString *)newPsw url:(NSString *)url completionHandler:(NetResponseCompletionBlock)completionBlock;



//Class Methods

+ (instancetype)sharedManager;

- (NSURLSessionDataTask *)requestWithMethod:(NSString *)method
                                       path:(NSString *)path
                                 parameters:(NSDictionary *)parameters
                                    overlay:(BOOL)overlay
                                 completion:(NetResponseCompletionBlock)completion;

- (NSURLSessionDataTask *)requestWithMethod:(NSString *)method
                                       path:(NSString *)path
                                 parameters:(NSDictionary *)parameters
                                    overlay:(BOOL)overlay
                                 completion:(NetResponseCompletionBlock)completion
                       commonSuccessHandler:(NetResponseSuccessBlock)commonSuccessHandler
                         commonErrorHandler:(CommonBlock)commonErrorHandler;

- (NSURLSessionDataTask *)requestWithMethod:(NSString *)method
                                       path:(NSString *)path
                                 parameters:(NSDictionary *)parameters
                                 completion:(NetResponseCompletionBlock)completion;


- (NSURLSessionDataTask *)requestWithMethod:(NSString *)method
                                       path:(NSString *)path
                                 parameters:(NSDictionary *)parameters
                                    overlay:(BOOL)overlay
                      overlayBaseView:(UIView*)overlayBaseView
                                 completion:(NetResponseCompletionBlock)completion
                       commonSuccessHandler:(NetResponseSuccessBlock)commonSuccessHandler
                         commonErrorHandler:(CommonBlock)commonErrorHandler;


//登录校验
#define MLoginCheck [kFILEPATH stringByAppendingString:@"api/v1/common/loginCheck"]
-(NSURLSessionDataTask *)login:(NSString *)mobile password:(NSString *)password overlayBaseView:(UIView*)overlayBaseView completionHandler:(NetResponseCompletionBlock)completionBlock;

//第三方登录
-(NSURLSessionDataTask *)oauthLogin:(NSString *)type openid:(NSString *)openid accessToken:(NSString *)accessToken device:(NSString *)device deviceid:(NSString *)deviceid overlayBaseView:(UIView*)overlayBaseView completionHandler:(NetResponseCompletionBlock)completionBlock;

//上传图片
//http://127.0.0.1:8080/ins/api/upload/image
//#define MUploadImage @"/ins/api/upload/image?token="
#define MUploadImage [kFILEPATH stringByAppendingString:@"api/v1/common/imgUpload"]
-(void)uploadImage:(UIImage *)image completionHandler:(NetFileUploadCompletionBlock)completionBlock;


// 上传签名图片
// 外网测试环境 ： http://192.168.1.191:8088/
// https://www.jscmwl.com/
// public static final String CAR_SERVICE ="http://101.132.100.176/cm/"
// 本地测试 http://192.168.1.192:8080
#define MUPloadSingImg   [kFILEPATH stringByAppendingString:@"api/v1/common/singImgUpload"]
- (void)uploadSingImage:(UIImage *)signImage userCode:(NSString *)userCode paraentVC:(UIViewController *)paraentVc completionHandler:(NetFileUploadCompletionBlock)completionBlock;


//上传音频   ischarge 是否为付费资源(非必填，默认0否) ,token
//http://127.0.0.1:8080/ins/api/upload/audio
#define MUploadAudio @"/ins/api/upload/audio?token="
-(void)uploadFile:(NSString *)filePath token:(NSString *)token completionHandler:(NetFileUploadCompletionBlock)completionBlock;

-(void)downloadFile:(NSString *)urlStr
         destination:(NSString *)destination
   completionHandler:(NetFileDownloadCompletionBlock)completionBlock;



@end
